package com.movisol.questionwizard.views;

import android.app.Activity;
import android.content.Context;
import android.media.AudioManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;

import com.movisol.questionwizard.applicationcontroller.ApplicationController;

public class Gallery extends Activity {
	
	private Context context;
	protected ApplicationController ac = ApplicationController.getInstance();
	private Button btnClose;
	private WebView webView;
	private static final int RESULT_START = 2;
	
	  
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	   super.onCreate(savedInstanceState);
   	       this.setVolumeControlStream(AudioManager.STREAM_MUSIC);  
    	   ac.setExit(true);
    	   context = ac.getContext();
    	   setContentView(R.layout.gallery);
    	   
    	   initializeControls();

    }

	private void initializeControls() {
		webView = (WebView) findViewById(R.id.webview);
		//Para que no se ponga en FullScreen
		webView.setWebViewClient(new WebViewClient()       
	    {
	         @Override
	        public boolean shouldOverrideUrlLoading(WebView view, String url) 
	        {
	            return false;
	        }
	    });
		webView.loadUrl(ac.getLiteralsValueByKey("gallery"+ac.getActiveProfileIndex()));
		webView.getSettings().setJavaScriptEnabled(true);
		btnClose = (Button) findViewById(R.id.btnClose);
		btnClose.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				setResult(RESULT_START);
				ac.setExit(false);
				finish();
				
			}
		});
		
	}

}
